package com.tomcat.servlet;


import java.io.IOException;
import java.io.OutputStream;

public class Response {

    //创建输出流
    private OutputStream outputStream;

    public Response(OutputStream outputStream) {
        this.outputStream = outputStream;
    }

    public static String getResponseHeader200(String context) {
        return "HTTP/1.1 200 \r\n" +
                "Content-Type:application/json \r\n" +
                "\r\n" + context;
    }


    public void GetWrite(Object context) throws IOException {
        outputStream.write(getResponseHeader200(context.toString()).getBytes());
    }

    public void Close() {
        try {
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
